package com.hsmpay.mobile.service.user.impl;

import com.hsmpay.common.service.impl.BaseServiceSupport;
import com.hsmpay.mobile.dao.user.ActivationCodeDao;
import com.hsmpay.mobile.pojo.user.ActivationCode;
import com.hsmpay.mobile.service.user.ActivationCodeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 激活码接口实现类 activationCodeService
 *
 * @param <Entity>
 * @param <Query>
 * @author 颜铃璋
 * @date 2012-12-17
 */
@Service("activationCodeService")
public class ActivationCodeServiceImpl extends BaseServiceSupport<ActivationCode, Long> implements ActivationCodeService<ActivationCode, Long> {
    @Resource(name = "activationCodeDao")
    private ActivationCodeDao<ActivationCode, Long> activationCodeDao;

    /**
     * 注册时 根据激活码 查询激活码对象
     *
     * @param code
     * @param terminalTypeId
     * @param roleId
     * @return
     * @throws Exception
     */
    public ActivationCode searchACodeToRegister(String code, Long terminalTypeId, Long roleId) throws Exception {
        ActivationCode activationCode = new ActivationCode();
        activationCode.setCode(code);
        activationCode.setEffective(1);//有效
        //activationCode.setIsActivation(0);//没有被注册的  被注册了在action中判断
        activationCode.setRoleId(roleId);
        activationCode.setTerminalTypeId(terminalTypeId);
        activationCode = activationCodeDao.searchEntity(activationCode);
        return activationCode;
    }

    //---------------------set get start----------------------
    //---------------------set get end------------------------
}
